package com.mh.aidldemo;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by kelii on 2018/3/8.
 */
public class AdditionService extends Service {
    IBinder mMyBinder = new MyBinder();
    List<Person> mPersonList = new ArrayList<>();

    public AdditionService() {
    }
    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;

    }

    IMyAidlInterface.Stub mBinder = new IMyAidlInterface.Stub() {
        @Override
        public int add(int x, int y) throws RemoteException {
            return x + y;
        }

        @Override
        public void addPerson(Person p) throws RemoteException {
            mPersonList.add(p);
        }

        @Override
        public List<Person> getPersonList() throws RemoteException {
            return mPersonList;
        }
    };

    class MyBinder extends Binder{
         public int addNum(int x, int y){
             return x + y;
         }

    }
}
